// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'

Shader "Hidden/Nature/Tree Soft Occlusion Bark Rendertex" {
Properties {
 _Color ("Main Color", Color) = (1,1,1,0)
 _MainTex ("Main Texture", 2D) = "white" { }
 _BaseLight ("Base Light", Range(0,1)) = 0.35
 _AO ("Amb. Occlusion", Range(0,10)) = 2.4
[HideInInspector]  _TreeInstanceColor ("TreeInstanceColor", Vector) = (1,1,1,1)
[HideInInspector]  _TreeInstanceScale ("TreeInstanceScale", Vector) = (1,1,1,1)
[HideInInspector]  _SquashAmount ("Squash", Float) = 1
}
SubShader { 
 Pass {
  Lighting On
  GpuProgramID 36863
CGPROGRAM
//#pragma target 4.0

#pragma vertex vert
#pragma fragment frag

#include "UnityCG.cginc"
#define conv_mxt4x4_0(mat4x4) float4(mat4x4[0].x,mat4x4[1].x,mat4x4[2].x,mat4x4[3].x)
#define conv_mxt4x4_1(mat4x4) float4(mat4x4[0].y,mat4x4[1].y,mat4x4[2].y,mat4x4[3].y)
#define conv_mxt4x4_2(mat4x4) float4(mat4x4[0].z,mat4x4[1].z,mat4x4[2].z,mat4x4[3].z)
#define conv_mxt4x4_3(mat4x4) float4(mat4x4[0].w,mat4x4[1].w,mat4x4[2].w,mat4x4[3].w)


#define CODE_BLOCK_VERTEX
//uniform float4x4 UNITY_MATRIX_MVP;
//uniform float4 glstate_lightmodel_ambient;
uniform float4 _TreeInstanceColor;
uniform float4 _TreeInstanceScale;
uniform float4x4 _TerrainEngineBendTree;
uniform float4 _SquashPlaneNormal;
uniform float _SquashAmount;
uniform float _AO;
uniform float _BaseLight;
uniform float4 _Color;
uniform float3 _TerrainTreeLightDirections[4];
uniform float4x4 _TerrainTreeLightColors;
uniform sampler2D _MainTex;
struct appdata_t
{
    float4 tangent :TANGENT;
    float4 vertex :POSITION;
    float4 color :COLOR;
    float3 normal :NORMAL;
    float4 texcoord :TEXCOORD0;
};

struct OUT_Data_Vert
{
    float4 xlv_TEXCOORD0 :TEXCOORD0;
    float4 xlv_TEXCOORD1 :TEXCOORD1;
    float4 vertex :SV_POSITION;
};

struct v2f
{
    float4 xlv_TEXCOORD0 :TEXCOORD0;
    float4 xlv_TEXCOORD1 :TEXCOORD1;
};

struct OUT_Data_Frag
{
    float4 color :SV_Target0;
};

OUT_Data_Vert vert(appdata_t in_v)
{
    OUT_Data_Vert out_v;
    float4 tmpvar_1;
    tmpvar_1 = in_v.color;
    float4 light_2;
    float4 lightColor_3;
    float4 lightDir_4;
    float4 tmpvar_5;
    float4 pos_6;
    pos_6.w = in_v.vertex.w;
    float alpha_7;
    alpha_7 = tmpvar_1.w;
    pos_6.xyz = (in_v.vertex.xyz * _TreeInstanceScale.xyz);
    float4 tmpvar_8;
    tmpvar_8.w = 0;
    tmpvar_8.xyz = pos_6.xyz;
    pos_6.xyz = lerp(pos_6.xyz, mul(_TerrainEngineBendTree, tmpvar_8).xyz, float3(alpha_7, alpha_7, alpha_7));
    float4 tmpvar_9;
    tmpvar_9.w = 1;
    tmpvar_9.xyz = lerp((pos_6.xyz - ((dot(_SquashPlaneNormal.xyz, pos_6.xyz) + _SquashPlaneNormal.w) * _SquashPlaneNormal.xyz)), pos_6.xyz, float3(_SquashAmount, _SquashAmount, _SquashAmount));
    pos_6 = tmpvar_9;
    lightDir_4.w = _AO;
    float4 tmpvar_10;
    tmpvar_10 = (glstate_lightmodel_ambient * 2);
    light_2 = tmpvar_10;
    float _tmp_dvx_240 = _TerrainTreeLightDirections[0];
    lightDir_4.xyz = float3(_tmp_dvx_240, _tmp_dvx_240, _tmp_dvx_240);
    lightColor_3 = conv_mxt4x4_0(_TerrainTreeLightColors);
    float tmpvar_11;
    tmpvar_11 = (_AO * in_v.tangent.w);
    light_2 = (light_2 + (lightColor_3 * (max(0, dot(in_v.normal, lightDir_4.xyz)) * (tmpvar_11 + _BaseLight))));
    float _tmp_dvx_241 = _TerrainTreeLightDirections[1];
    lightDir_4.xyz = float3(_tmp_dvx_241, _tmp_dvx_241, _tmp_dvx_241);
    lightColor_3 = conv_mxt4x4_1(_TerrainTreeLightColors);
    light_2 = (light_2 + (lightColor_3 * (max(0, dot(in_v.normal, lightDir_4.xyz)) * (tmpvar_11 + _BaseLight))));
    float _tmp_dvx_242 = _TerrainTreeLightDirections[2];
    lightDir_4.xyz = float3(_tmp_dvx_242, _tmp_dvx_242, _tmp_dvx_242);
    lightColor_3 = conv_mxt4x4_2(_TerrainTreeLightColors);
    light_2 = (light_2 + (lightColor_3 * (max(0, dot(in_v.normal, lightDir_4.xyz)) * (tmpvar_11 + _BaseLight))));
    float _tmp_dvx_243 = _TerrainTreeLightDirections[3];
    lightDir_4.xyz = float3(_tmp_dvx_243, _tmp_dvx_243, _tmp_dvx_243);
    lightColor_3 = conv_mxt4x4_3(_TerrainTreeLightColors);
    light_2.xyz = (light_2 + (lightColor_3 * (max(0, dot(in_v.normal, lightDir_4.xyz)) * (tmpvar_11 + _BaseLight)))).xyz;
    light_2.w = 1;
    tmpvar_5.xyz = ((light_2 * _Color) * _TreeInstanceColor).xyz;
    tmpvar_5.w = 1;
    out_v.vertex = UnityObjectToClipPos(tmpvar_9);
    out_v.xlv_TEXCOORD0 = in_v.texcoord;
    out_v.xlv_TEXCOORD1 = tmpvar_5;
    return out_v;
}

#define CODE_BLOCK_FRAGMENT
OUT_Data_Frag frag(v2f in_f)
{
    OUT_Data_Frag out_f;
    float4 col_1;
    col_1 = in_f.xlv_TEXCOORD1;
    col_1.xyz = (col_1.xyz * tex2D(_MainTex, in_f.xlv_TEXCOORD0.xy).xyz);
    col_1.w = 1;
    out_f.color = col_1;
    return out_f;
}


ENDCG

}
}
Fallback Off
}